package com.czmc.smalldemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import net.wequick.small.Small;

public class LaunchActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launcher);
    }

    @Override
    protected void onStart() {
        super.onStart();
//        Small.setBaseUri("http://example.com/");
        Small.setUp(LaunchActivity.this, new Small.OnCompleteListener() {
            @Override
            public void onComplete() {
                checkUpdate();
            }
        });
    }

    public void checkUpdate() {
        UpgradeManager.ins(this).checkUpgrade(  new UpgradeManager.OnUpgradeListener() {
            @Override
            public void onUpgrade(boolean succeed) {
//                String text = succeed ?
//                        "Upgrade Success! Switch to background and back to foreground to see changes."
//                        : "Upgrade Failed!";
//                Toast.makeText(LaunchActivity.this, text, Toast.LENGTH_SHORT).show();
                doStart();
            }
        });
    }
    private void doStart(){
            Small.openUri("main", LaunchActivity.this);
            finish();
    }


}
